package org.example.types.design.link;


/**
 * @author yinghuashen
 * @version 1.0
 * @description
 * @date 2025/3/7 23:40
 */

public abstract class AbstractLogicLinkNode<T, D, R> {

    protected AbstractLogicLinkNode<T, D, R> next;

    public abstract R execute(T t, D d);

    public AbstractLogicLinkNode<T, D, R> setNext(AbstractLogicLinkNode<T, D, R> next) {
        this.next = next;
        return next;
    }

    public AbstractLogicLinkNode<T, D, R> getNext() {
        return next;
    }

    protected R executeNext(T t, D d) {
        if (next != null) {
            return next.execute(t, d);
        }
        return null;
    }
}
